<?php
namespace app\backend\org;

class Recursion
{
    //获取某个分类下的所有子类id，返回一维数组
    static public function _child_id($data, $pid=0){
        $array = array();
        foreach($data as $k => $v){
            if ($v['p_id'] == $pid){
                $array[] = $v['menu_id'];
                unset($data[$k]);
                $array = array_merge($array, self::_child_id($data, $v['menu_id'])); //递归
            }
        }
        return $array;
    }

// //获取某个分类下的直系子类id，返回一维数组
    /*static public function _imchild_id($data,$kdey_id){
        $array = array();
        foreach($data as $k => $v){
            if ($v['p_id'] == $kdey_id){
                $array[] = $v['nav_id'];
                unset($data[$k]);
                $array = array_merge($array, self::_imchild_id($data, $v['nav_id'])); //递归
            }
        }
        return $array;
    }*/
    //分类级别
    /*static protected function _cate_level($data, $pid=0, $level=0){
        $array = array();
        foreach ($data as $k => $v){
            if ($v['p_id'] == $pid){
                $v['level'] = $level;
                $array[] = $v;
                unset($data[$k]);
                $array = array_merge($array, self::_cate_level($data, $v['nav_id'],$level+1)); //递归
            }
        }
        return $array;
    }*/

    //菜单
   /* static protected function _get_child($data, $pid=0){
        $array = array();
        foreach ($data as $k => $v){
            if ($v['p_id'] == $pid){
                $v['child'] = self::_get_child($data, $v['service_id']); //递归
                $array[] = $v;
            }
        }
        return $array;
    }*/
}